#!/bin/sh
INOTIFY_CMD="inotifywait -mrq -e modify,create,attrib,move,delete root_path"
$INOTIFY_CMD | while read FILE
do
   echo "FILE is : "$FILE >> /var/log/rsyncd.log
   fileDir=$(echo $FILE | awk '{print $1}')
   fileEvent=$(echo $FILE | awk '{print $2}')
   fileName=$(echo $FILE | awk '{print $2}')
   if [[ $fileDir =~ ^'root_path'.* ]]; then
      rsync -vzrtopgl --progress --delete --files-from='/etc/rsync/rsync/module/include.txt' --exclude-from='/etc/rsync/rsync/module/exclude.txt' --password-file=/etc/rsync/rsync_client.password root_path rsync_user@opposite_ip::module
   fi
done
